Skip to content

simplify converter - #544

Merged
wpbonelli merged 8 commits into
modflowpy:developfrom
wpbonelli:simplify-converter
Nov 6, 2026
Merged

wpbonelli merged 8 commits into
modflowpy:developfrom
wpbonelli:simplify-converter

Conversation

@wpbonelli

@wpbonelli wpbonelli commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

IO architecture is currently like

component.load()/write() -> conversion -> serialization

where conversion means reshaping the data from the in-memory representation to one appropriate for serialization, i.e. turning instances of generated classes into builtin (or "de facto stdlib packages" e.g. numpy or pandas) collections and/or primitives at write time, vice versa on load.

previously this was pretty gross, with a lot of special casing and duplicative logic. make it all schema-driven, with the generated classes as the schema: codegen compiles the DFNs into class fields and metadata, and the converter reads those. one loop instead of seven, one array reader instead of three, one runtime schema instead of two

"simplify" here does not necessarily mean fewer LOC, sadly.

one API change sneaking in: GWF, CHF and OLF STO stress_period_data is now {0: "steady-state"}, Sto.StressPeriodData is gone, flopy3 steady_state and transient kwargs still work

also add two load validations that used to pass: a block missing its END (a BEGIN inside a block, or an END naming another block) and a bad MAXBOUND (e.g. MAXBOUND two) now raise ValueError instead of warning or loading silently, as MF6 stops on both

@wpbonelli wpbonelli added this to the MMP milestone Nov 5, 2026
@wpbonelli wpbonelli added refactor question Information or decisions required labels Nov 5, 2026
wpbonelli and others added 8 commits November 5, 2026 17:06
One schema-driven model of an MF6 block in both directions: stored DFNs
and spec helpers, the rewritten loader (_Load), one egress path
(_Unstructure), header kinds, and STO's period value as a word per period.

Rebased onto develop be07090, with develop's changes ported into the
rewritten paths: binary list input, array reading (modflowpy#513), external list
writing (ListIO), binding rows (read_row/write_row), text tokens (modflowpy#534).

The typed loader and its grammar work are dropped here, back to develop's;
they're on typed-loader-parked, to go on a branch stacked on this one.
_Load keeps its ComponentLoad base for that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The report compares against a typed loader that isn't here, so it moves
to typed-loader. Restore develop's load-benchmarks.md, which said that
loader could be used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
flopy4 mf6 sync writes them, so GitHub can collapse them in diffs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Plans live on dev-plans, not develop, so it shouldn't land with this.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sync formats its output only where ruff is on the PATH, and the test
environments don't install it, so test_installed_dfns_match_classes failed
there on formatting alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The basic loader took a BEGIN inside a block as a row and any name after END,
so a block missing its END swallowed the next one, with only a warning. It
also ignored MAXBOUND's value, since MAXBOUND is computed. MF6 stops on both,
so raise, naming the block and line or the entry. An unknown row or block
still warns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The loader's block structure came from DFNs stored with the classes and its
values from the classes, joined by attr_names, which reran codegen's spec at
load. The classes lacked only one fact to stand alone, which fields are
untagged, and that's in the DFNs already. So codegen emits tagged=False, and
spec.file_blocks and spec.block_keys route on attrs fields.

Remove flopy4/mf6/dfns, _store_dfns, spec.dfn, attr_names and make._headers.
test_mf6_routing.py holds generated classes to the DFNs they came from.

unstructure_component's keys are now each field's name in the file (sfac),
not the DFN's name for it (sfacrecord).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… develop

STO's value in these 37 is one word per period again. Against this branch
before the rebase, they differ only by modflowpy#546's names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
wpbonelli added a commit to wpbonelli/pyphoenix-project that referenced this pull request Nov 6, 2026
factoring.md says where a constraint or format fact belongs: the DFN, the
classes, the codec or a named check. It also says when the DFN should stop
growing, and lists three structural changes that remove constraints. The
converter plan records that modflowpy#544 no longer reads stored DFNs at runtime.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wpbonelli wpbonelli added the bug Something isn't working label Nov 6, 2026
@wpbonelli
wpbonelli marked this pull request as ready for review November 6, 2026 01:40
@wpbonelli
wpbonelli merged commit 23bd606 into modflowpy:develop Nov 6, 2026
18 checks passed
@wpbonelli
wpbonelli deleted the simplify-converter branch November 6, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working question Information or decisions required refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant